package cn.ikun.mzw;

import java.lang.reflect.Method;

public class Mengzhiwei {
    public static void main(String [] args) throws Exception {
        //String s=RandomStringUtils.randomAlphabetic(6);
        //System.out.println(s);

        //创建java的实例
        User u = new User();
        u.setName("Weio");

        User v = new User();
        v.setAge(18);

        System.out.println(u.getName());
        System.out.println(v.getAge());

        // ------------------------------------------------------------------


        Class<?> UU = Class.forName("cn.ikun.mzw.User");

        Object o = UU.newInstance();
        Object p = UU.newInstance();

        Method setName = UU.getMethod("setName", String.class);
        Method setAge = UU.getMethod("setAge", Integer.class);

        setName.invoke(o,"Jenkins");
        setAge.invoke(p,20);

        Method getName = UU.getMethod("getName");
        Method getAge = UU.getMethod("getAge");

        Object result = getName.invoke(o);
        Object result1 = getAge.invoke(p);

        System.out.println(result);
        System.out.println(result1);



    }
}
